<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/header.ftl" />
</head>

<script>
    $(function () {
        //推荐时间设置日历
        $("#editForm input[name='schedule']").click(function () {
            minDate();
        });
        //取消发布按钮
        $(".changeStateBtn").click(function () {
            var state = $(this).data("state");
            var id = $(this).data("tid");
            $.get("/travel/changeState.do",{id:id,state:state},function (data) {
                reload();
            })
        });
        //查看文章按钮
        $(".contentBtn").click(function () {
            var id = $(this).data("tid");
            $.get("/travelContent/selectContent.do",{id:id},function (data) {
                $(".modal-body").html(data.content);
                $("#travelContentModel").modal("show");
            })
        });
        //推荐按钮
        $(".recommendBtn").click(function () {
            $("#travelContentModel input").val("");
            $("#travelContentModel input").val("");
            var json = $(".recommendBtn").data("json");
            $("#editForm input[name='title']").val(json.title);
            $("#editForm img[name='coverUrl']").attr("src",json.coverUrl);
            $("#editForm input[name='travel.id']").val(json.travelId);
            $("#travelCommendModel").modal("show");
        });
        //推荐模态框的保存按钮
        $(".submitButton").click(function () {
            $("#editForm").ajaxSubmit(function (data) {
                reload();
            });
        });
    })
</script>
<body>
<!-- 推荐按钮的模态框（Modal） -->
<div class="modal fade" id="travelCommendModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">新增游记推荐</h4>
            </div>
            <div class="modal-body">
            </div>
            <form class="form-horizontal" action="/travelCommend/saveOrUpdate.do" method="post" id="editForm">
                <input type="hidden" name="travel.id">
                <div class="form-group" >
                    <label for="name" class="col-sm-4 control-label">标题：</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" name="title">
                    </div>
                </div>
                <div class="form-group" >
                    <label for="name" class="col-sm-4 control-label">副标题：</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" name="subTitle">
                    </div>
                </div>
                <div class="form-group" >
                    <label for="name" class="col-sm-4 control-label">封面：</label>
                    <div class="col-sm-6">
                        <img name="coverUrl" width="100%">
                        <input type="file"  class="form-control" name="file">
                    </div>
                </div>

                <div class="form-group">
                    <label for="sn" class="col-sm-4 control-label">推荐时间：</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" name="schedule">
                    </div>
                </div>
                <div class="form-group">
                    <label for="sn" class="col-sm-4 control-label">推荐类型：</label>
                    <div class="col-sm-6">
                        <select class="form-control" name="type">
                            <option value="1">每周推荐</option>
                            <option value="2">每月推荐</option>
                            <option value="3">攻略推荐</option>
                        </select>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dism`iss="modal">关闭</button>
                    <button type="button" class="btn btn-primary submitButton">保存</button>
                </div>
            </form>
        </div><!-- /.modal-content -->
    </div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>

<!-- 查看文章的模态框（Modal） -->
<div class="modal fade" id="travelContentModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">文章内容</h4>
            </div>
            <#--游记内容-->
            <div class="modal-body">
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<#-- 设置模态框内图片的样式 -->
<style>
    #travelContentModel img{
        width: 100%;
    }
</style>
<#-- 关闭时清楚模态框缓存 -->
<script>
    $(function () {
        $("#travelContentModel").on('hidden.bs.modal',function () {
            $(this).removeData('bs.modal');
        });
        $("#travelCommendModel").on('hidden.bs.modal',function () {
            $(this).removeData('bs.modal');
        })
    })
</script>

<form class="form-inline" id="searchForm" action="/travel/releaseList.do" method="post">
    <input type="hidden" name="currentPage" id="currentPage">
</form>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl" />
    <div class="row">
        <div class="col-sm-3">
            <#assign menu="releaseList"/>
            <#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">已发布游记列表</h1>
                </div>
            </div>
            <table class="table table-striped table-hover" >
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>封面</th>
                    <th>地点</th>
                    <th>作者</th>
                    <th>发布时间</th>
                    <th>状态</th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                       <td>${entity_index + 1}</td>
                       <td>${entity.title}</td>
                       <td><img src="${entity.coverUrl}" width="30px"> </td>
                       <td>${entity.place.name}</td>
                       <td>${entity.author.nickName}</td>
                       <td>${entity.releaseTime?string("yyyy-MM-dd")}</td>
                       <td>${entity.stateName}</td>
                        <td>
                            <a class="btn btn-info btn-xs btn-input changeStateBtn" data-state="-1" data-tid="${entity.id}">
                                <span class="glyphicon glyphicon-ban-circle"></span>取消发布
                            </a>
                            <a class="btn btn-info btn-xs btn-input contentBtn"  data-tid="${entity.id}">
                                <span class="glyphicon glyphicon-pencil"></span>查看文章
                            </a>
                            <a class="btn btn-info btn-xs btn-input recommendBtn" data-json='${entity.json}'>
                                <span class="glyphicon glyphicon-heart"></span>推荐
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl" />
        </div>
    </div>
</div>

<script>

</script>
</body>
</html>